using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vTransferAuditMap : EntityTypeConfiguration<vTransferAudit>
    {
        public vTransferAuditMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Number, t.date, t.source, t.dest });

            // Properties
            this.Property(t => t.Number)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Note)
                .HasMaxLength(50);

            this.Property(t => t.userno)
                .HasMaxLength(10);

            this.Property(t => t.transfertype)
                .HasMaxLength(3);

            this.Property(t => t.source)
                .IsRequired()
                .HasMaxLength(3);

            this.Property(t => t.dest)
                .IsRequired()
                .HasMaxLength(3);

            // Table & Column Mappings
            this.ToTable("vTransferAudit");
            this.Property(t => t.Number).HasColumnName("Number");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.date).HasColumnName("date");
            this.Property(t => t.userno).HasColumnName("userno");
            this.Property(t => t.transfertype).HasColumnName("transfertype");
            this.Property(t => t.source).HasColumnName("source");
            this.Property(t => t.dest).HasColumnName("dest");
            this.Property(t => t.posted).HasColumnName("posted");
            this.Property(t => t.outtransfernum).HasColumnName("outtransfernum");
        }
    }
}
